From: Jonas Dreßler Date: Wed, 25 Apr 2018 21:24:05 +0000 (+0200) Subject: switcherPopup: Use local variable for index in scrolling functions X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~772^2^2~30 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=172d21cf506e5fb6f49d4bad344323e289365442;p=gnome-shell.git switcherPopup: Use local variable for index in scrolling functions Make sure the index that's being scrolled to doesn't change while the scrolling animation is running by using an argument instead of the this._highlighed class scope variable. This fixes wrongly shown arrows when selecting new elements faster than the scrolling animation takes for one index. The check run to disable the arrow might be checking against a newer index than the one at the start of the animation which results in the arrow not getting hidden even if no more scrolling is possible. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/167 --- diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js index d026453ca..16aa24c64 100644 --- a/js/ui/switcherPopup.js +++ b/js/ui/switcherPopup.js @@ -467,17 +467,17 @@ var SwitcherList = GObject.registerClass({ let [result_, posX, posY_] = this.transform_stage_point(absItemX, 0); let [containerWidth] = this.get_transformed_size(); if (posX + this._items[index].get_width() > containerWidth) - this._scrollToRight(); + this._scrollToRight(index); else if (this._items[index].allocation.x1 - value < 0) - this._scrollToLeft(); + this._scrollToLeft(index); } - _scrollToLeft() { + _scrollToLeft(index) { let adjustment = this._scrollView.hscroll.adjustment; let [value, lower_, upper, stepIncrement_, pageIncrement_, pageSize] = adjustment.get_values(); - let item = this._items[this._highlighted]; + let item = this._items[index]; if (item.allocation.x1 < value) value = Math.min(0, item.allocation.x1); @@ -489,18 +489,18 @@ var SwitcherList = GObject.registerClass({ progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD, duration: POPUP_SCROLL_TIME, onComplete: () => { - if (this._highlighted == 0) + if (index === 0) this._scrollableLeft = false; this.queue_relayout(); }, }); } - _scrollToRight() { + _scrollToRight(index) { let adjustment = this._scrollView.hscroll.adjustment; let [value, lower_, upper, stepIncrement_, pageIncrement_, pageSize] = adjustment.get_values(); - let item = this._items[this._highlighted]; + let item = this._items[index]; if (item.allocation.x1 < value) value = Math.max(0, item.allocation.x1); @@ -512,7 +512,7 @@ var SwitcherList = GObject.registerClass({ progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD, duration: POPUP_SCROLL_TIME, onComplete: () => { - if (this._highlighted == this._items.length - 1) + if (index === this._items.length - 1) this._scrollableRight = false; this.queue_relayout(); },